package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.ViewMapData;
import com.ruoyi.system.service.IViewMapDataService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * VIEWController
 * 
 * @author ruoyi
 * @date 2023-06-30
 */
@Api("首页")
@RestController
@RequestMapping("/system/map")
public class ViewMapDataController extends BaseController
{
    @Autowired
    private IViewMapDataService viewMapDataService;

    /**
     * 查询VIEW列表
     */
    @ApiOperation("获取首页信息")
    @PreAuthorize("@ss.hasPermi('system:map:list')")
    @GetMapping("/list")
    public TableDataInfo list(ViewMapData viewMapData)
    {
        List<ViewMapData> list = viewMapDataService.selectViewMapDataList(viewMapData);
        return getDataTable(list);
    }

    /**
     * 导出VIEW列表
     */
    @PreAuthorize("@ss.hasPermi('system:map:export')")
    @Log(title = "VIEW", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, ViewMapData viewMapData)
    {
        List<ViewMapData> list = viewMapDataService.selectViewMapDataList(viewMapData);
        ExcelUtil<ViewMapData> util = new ExcelUtil<ViewMapData>(ViewMapData.class);
        util.exportExcel(response, list, "VIEW数据");
    }

    /**
     * 获取VIEW详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:map:query')")
    @GetMapping(value = "/{address}")
    public AjaxResult getInfo(@PathVariable("address") String address)
    {
        return success(viewMapDataService.selectViewMapDataByAddress(address));
    }

    /**
     * 新增VIEW
     */
    @PreAuthorize("@ss.hasPermi('system:map:add')")
    @Log(title = "VIEW", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody ViewMapData viewMapData)
    {
        return toAjax(viewMapDataService.insertViewMapData(viewMapData));
    }

    /**
     * 修改VIEW
     */
    @PreAuthorize("@ss.hasPermi('system:map:edit')")
    @Log(title = "VIEW", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody ViewMapData viewMapData)
    {
        return toAjax(viewMapDataService.updateViewMapData(viewMapData));
    }

    /**
     * 删除VIEW
     */
    @PreAuthorize("@ss.hasPermi('system:map:remove')")
    @Log(title = "VIEW", businessType = BusinessType.DELETE)
    @DeleteMapping("/{addresss}")
    public AjaxResult remove(@PathVariable String[] addresss)
    {
        return toAjax(viewMapDataService.deleteViewMapDataByAddresss(addresss));
    }
}
